home *** CD-ROM | disk | FTP | other *** search
- Path: abcfd20.larc.nasa.gov!amiga-request
- From: amiga-request@abcfd20.larc.nasa.gov (Amiga Sources/Binaries Moderator)
- Subject: v90i228: flex 2.3 - fast lexical analyzer generator, Part01/13
- Reply-To: loftus@wpllabs.uucp (William P Loftus)
- Newsgroups: comp.sources.amiga
- Message-ID: <comp.sources.amiga:v90i228@abcfd20.larc.nasa.gov>
- Date: 19 Aug 90 22:41:53 GMT
- Approved: tadguy@uunet.UU.NET (Tad Guy)
- X-Mail-Submissions-To: amiga@uunet.uu.net
- X-Post-Discussions-To: comp.sys.amiga
-
- Submitted-by: loftus@wpllabs.uucp (William P Loftus)
- Posting-number: Volume 90, Issue 228
- Archive-name: unix/flex-2.3/part01
-
- [ the flexdoc.doc file was uuencoded to preserve formatting, and it
- and flexdoc.1 were split ...tad ]
-
- [ from the flexdoc file... ]
-
- flex is a tool for generating scanners: programs which
- recognized lexical patterns in text. flex reads the given
- input files, or its standard input if no file names are
- given, for a description of a scanner to generate. The
- description is in the form of pairs of regular expressions
- and C code, called rules. flex generates as output a C
- source file, lex.yy.c, which defines a routine yylex(). This
- file is compiled and linked with the -lfl library to produce
- an executable. When the executable is run, it analyzes its
- input for occurrences of the regular expressions. Whenever
- it finds one, it executes the corresponding C code.
-
- #!/bin/sh
- # This is a shell archive. Remove anything before this line, then unpack
- # it by saving it into a file and typing "sh file". To overwrite existing
- # files, type "sh file -c". You can also feed this as standard input via
- # unshar, or by typing "sh <file", e.g.. If this archive is complete, you
- # will see the following message at the end:
- # "End of archive 1 (of 13)."
- # Contents: Amiga.notes COPYING MISC MISC/MSDOS.notes
- # MISC/Makefile.VMS MISC/README MISC/Turbo-C.notes Makefile
- # Makefile.amiga README ccl.c ecs.c flexdoc.uu.ac libmain.c parse.h
- # sym.c yylex.c
- # Wrapped by tadguy@abcfd20 on Sun Aug 19 18:41:41 1990
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'Amiga.notes' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'Amiga.notes'\"
- else
- echo shar: Extracting \"'Amiga.notes'\" \(1144 characters\)
- sed "s/^X//" >'Amiga.notes' <<'END_OF_FILE'
- X(1) Makefile modifications
- X
- X o Removed Unix depended commands and conventions
- X
- X o Made Makefile bison specific (isn't there a bison option to make it act like
- X yacc, i.e., generate y.tab.c instead of parse.tab.c?)
- X
- X o Amiga Makefile is called "Makefile.amiga"
- X
- X(2) flexdef.h modifications (because of makefile problem)
- X
- X o Cannot get quotes to work correctly with AmigaDOS and LMK.
- X moved this define to flexdef.h (between ifdef AMIGA...endif) wpl 7/14/90
- X
- X Affected makefile line:
- X #SKELFLAGS = -dDEFAULT_SKELETON_FILE="$(SKELETON_FILE)"
- X
- X(3) parse.y
- X
- X o Added following prototypes:
- X
- X void build_eof_action();
- X void yyerror( char * );
- X
- X(4) scan.l
- X
- X o Added case "return ( (int) yytext[0] )"
- X
- X(5) flex.skel
- X
- X o Added keyword "register" to following prototypes:
- X
- X static yy_state_type yy_try_NUL_trans
- X YY_PROTO(( register yy_state_type current_state ));
- X
- X static void yyunput YY_PROTO(( YY_CHAR c,
- X register YY_CHAR *buf_ptr ));
- X
- X(6) main.c
- X
- X o changed mktemp call to a call to TmpFileName and added TmpFileName
- X routine.
- X
- X char *
- X TmpFileName(template)
- X
- END_OF_FILE
- if test 1144 -ne `wc -c <'Amiga.notes'`; then
- echo shar: \"'Amiga.notes'\" unpacked with wrong size!
- fi
- # end of 'Amiga.notes'
- fi
- if test -f 'COPYING' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'COPYING'\"
- else
- echo shar: Extracting \"'COPYING'\" \(1802 characters\)
- sed "s/^X//" >'COPYING' <<'END_OF_FILE'
- XFlex carries the copyright used for BSD software, slightly modified
- Xbecause it originated at the Lawrence Berkeley (not Livermore!) Laboratory,
- Xwhich operates under a contract with the Department of Energy:
- X
- X Copyright (c) 1990 The Regents of the University of California.
- X All rights reserved.
- X
- X This code is derived from software contributed to Berkeley by
- X Vern Paxson.
- X
- X The United States Government has rights in this work pursuant
- X to contract no. DE-AC03-76SF00098 between the United States
- X Department of Energy and the University of California.
- X
- X Redistribution and use in source and binary forms are permitted
- X provided that: (1) source distributions retain this entire
- X copyright notice and comment, and (2) distributions including
- X binaries display the following acknowledgement: ``This product
- X includes software developed by the University of California,
- X Berkeley and its contributors'' in the documentation or other
- X materials provided with the distribution and in all advertising
- X materials mentioning features or use of this software. Neither the
- X name of the University nor the names of its contributors may be
- X used to endorse or promote products derived from this software
- X without specific prior written permission.
- X
- X THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- X IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- X WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- X PURPOSE.
- X
- XThis basically says "do whatever you please with this software except
- Xremove this notice or take advantage of the University's (or the flex
- Xauthors') name".
- X
- XNote that the "flex.skel" scanner skeleton carries no copyright notice.
- XYou are free to do whatever you please with scanners generated using flex;
- Xfor them, you are not even bound by the above copyright.
- END_OF_FILE
- if test 1802 -ne `wc -c <'COPYING'`; then
- echo shar: \"'COPYING'\" unpacked with wrong size!
- fi
- # end of 'COPYING'
- fi
- if test ! -d 'MISC' ; then
- echo shar: Creating directory \"'MISC'\"
- mkdir 'MISC'
- fi
- if test -f 'MISC/MSDOS.notes' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'MISC/MSDOS.notes'\"
- else
- echo shar: Extracting \"'MISC/MSDOS.notes'\" \(5328 characters\)
- sed "s/^X//" >'MISC/MSDOS.notes' <<'END_OF_FILE'
- X$Header:$
- X
- XNotes on Porting flex to MS-DOS
- X-------------------------------
- X
- X[These notes were last revised 30Dec89 for flex release 2.2.]
- X
- XPrevious releases of flex have been successfully built using Microsoft C and
- Xthe following options: /AL, /stack:10000, -LARGE, -Ml, -Mt128, -DSYS_V
- X
- XOther folks report that the following work for MSC 5.1 under DOS and OS/2:
- X
- X CFLAGS=-ALu -F 8000 -Gt16000 -Ox -DMS_DOS -DSYS_V -D__RUNTIME_YYMAXDEPTH
- X LINKFLAGS=/E /FAR /PAC /NOI
- X
- XWhere you may want to adjust -F up in order to increase available stack
- Xsize (though it may not be necessary) and you may want to increase -Gt
- Xto some number that puts just enought of the big data items in their own
- Xdata segments. (The default for -Gt is items of 32k. This is too high for
- Xflex.) __RUNTIME_YYMAXDEPTH is useful if you have a parse.c that's
- Xbeen generated by a yacc that understands how to do this; otherwise, it's a
- Xno-op.
- X
- XJeffrey R. Jones (jjones@angate.att.com) writes [this has been edited -vp]:
- X
- X.... The port was accomplished with:
- X
- X AT&T 6312 WGS (12 Mhz AT class machine)
- X Microsoft C compiler Version 5.0
- X 'make' utility from Aztec-C package (subset of unix-make)
- X
- XThe re-done makefile is included .... Do what you wish with it.
- X
- X
- X[note that this Makefile is now slightly out of date and has not been
- X tested with flex 2.2]
- X
- X# This makefile is used to port the flex 2.1 build to a PC. The compiler is
- X# Microsoft-C Version 5.0 while the 'make' utility came with Aztec-C, which
- X# is VERY compatible with Unix's make. There are a few things that Aztec-C's
- X# 'make' can't do that unix does so I have made a few minor changes.
- X# At the least you can manually compile each file and then link.
- X# The linker and library utilities are alos Microsoft's.
- X#
- X# Additionally, after building with the large model, the flex.map reveals that
- X# code-size is less than 64K, therefore, in favor of a little more execution
- X# efficiency, I built with the compact model. I've used the default compiler
- X# optimization (no /O switches).
- X#
- X# The linker must be told to increase the run-time stack space. The default
- X# stack space is 2048. Flexing scan.l with the default stack-space results in
- X# a run-time stack overflow, hence the stack was increase to 4096.
- X#
- X# NOTE: I have MKS-Toolkit's yacc and was able to use it with virtually no
- X# modifications to anything. If you don't have yacc for a PC, you can try
- X# yaccing on a unix system and downloading the resulting files to the PC.
- X#
- X# Jeffrey R. Jones
- X# jjones@angate!att.com
- X
- X
- X# make file for "flex" tool
- X
- X# @(#) $Header: Makefile,v 2.3 89/06/20 17:27:12 vern Exp $ (LBL)
- X
- X# Porting considerations:
- X#
- X# For System V Unix machines, add -DSYS_V to CFLAGS.
- X# For Vax/VMS, add -DSYS_V to CFLAGS.
- X# For MS-DOS, add "-DMS_DOS -DSYS_V" to CFLAGS. Create \tmp if not present.
- X# You will also want to rename flex.skel to something with a three
- X# character extension, change SKELETON_FILE below appropriately,
- X# For Amiga, add "-DAMIGA -DSYS_V" to CFLAGS.
- X
- X
- X# the first time around use "make first_flex"
- X
- X
- XYACC=yacc
- XSKELETON_DIR = c:/usr/contrib/lib
- XSKELETON_FILE = flex.ske
- XSKELFLAGS = -DDEFAULT_SKELETON_FILE=\"$(SKELETON_DIR)/$(SKELETON_FILE)\"
- XCFLAGS = -c -AC -DMS_DOS -DSYS_V
- XLDFLAGS = /noi /cp:1 /stack:4096
- X
- X#this null definition prevents a returned error code
- XMFLAGS =
- X
- XFLEX_FLAGS =
- XFLEX = flex
- XCC = cl
- X
- X# redefine Aztec make's built-in rule
- X.c.obj:
- X $(CC) $(CFLAGS) $*.c
- X
- X# break obj-list into two because of 128 character command-line limit of
- X# Microsoft's link and lib utilities.
- XFLEXOBJS1 = ccl.obj dfa.obj ecs.obj gen.obj main.obj misc.obj nfa.obj parse.obj
- XFLEXOBJS2 = scan.obj sym.obj tblcmp.obj yylex.obj
- X
- XFLEX_C_SOURCES = \
- X ccl.c \
- X dfa.c \
- X ecs.c \
- X gen.c \
- X main.c \
- X misc.c \
- X nfa.c \
- X parse.c \
- X scan.c \
- X sym.c \
- X tblcmp.c \
- X yylex.c
- X
- X# lib is used to get around the 128 character command-line limit of 'link'.
- Xflex.exe : $(FLEXOBJS1) $(FLEXOBJS2)
- X lib tmplib $(FLEXOBJS1);
- X link $(LDFLAGS) $(FLEXOBJS2),$*.exe,,tmplib;
- X rm -f tmplib.lib
- X
- X# the second 'make flex.exe' causes scan.l to be RE-flexed. The resulting
- X# scan.c is different from initscan.c in that \r\n are added instead of
- X# just \n. Since \r\n is DOS language and this is targetted for PCs, and
- X# since I don't know what would happen for all cases in DOS-land, I went
- X# ahead and did it.
- Xfirst_flex:
- X cp initscan.c scan.c
- X make $(MFLAGS) flex.exe
- X rm -f scan.c
- X make flex.exe
- X
- Xparse.obj: parse.c parse.h
- X
- Xparse.h parse.c : parse.y
- X $(YACC) -d parse.y
- X @mv ytab.c parse.c
- X @mv ytab.h parse.h
- X
- Xscan.c : scan.l
- X $(FLEX) -ist $(FLEX_FLAGS) scan.l > scan.c
- X
- Xscan.obj : scan.c parse.h
- X
- Xmain.obj : main.c
- X $(CC) $(CFLAGS) $(SKELFLAGS) main.c
- X
- X###################
- X#don't have, or need, anything else except maybe the 'test' rule.
- X#
- X# don't have nroff
- X#flex.man : flex.1
- X# nroff -man flex.1 >flex.man
- X#
- X# don't have lint
- X#lint : $(FLEX_C_SOURCES)
- X# lint $(FLEX_C_SOURCES) > flex.lint
- X#
- X#distrib :
- X# mv scan.c initscan.c
- X# chmod 444 initscan.c
- X# $(MAKE) $(MFLAGS) clean
- X#
- X#clean :
- X# rm -f core errs flex *.o parse.c *.lint parse.h flex.man tags
- X#
- X#tags :
- X# ctags $(FLEX_C_SOURCES)
- X#
- X#vms : flex.man
- X# $(MAKE) $(MFLAGS) distrib
- X#
- X# break this up into multiple lines...Aztec 'make' limitation
- Xtest :
- X $(FLEX) -ist $(FLEX_FLAGS) scan.l > scan.tst
- X diff scan.c scan.tst
- X rm -f scan.tst
- END_OF_FILE
- if test 5328 -ne `wc -c <'MISC/MSDOS.notes'`; then
- echo shar: \"'MISC/MSDOS.notes'\" unpacked with wrong size!
- fi
- # end of 'MISC/MSDOS.notes'
- fi
- if test -f 'MISC/Makefile.VMS' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'MISC/Makefile.VMS'\"
- else
- echo shar: Extracting \"'MISC/Makefile.VMS'\" \(3537 characters\)
- sed "s/^X//" >'MISC/Makefile.VMS' <<'END_OF_FILE'
- X############################ VMS MAKEFILE ##############################
- X#IMPORTANT: Before you use this makefile fill in the contents of GNULIB.
- X#
- X# Define tools$$exe, tools$$library, and tools$$manual to reflect the
- X# locations where you would like to store the executables, library (flex.skel)
- X# and the manual pages. These names can be defined at the command line
- X# prompt: eg.
- X# $ define tools$$exe disk:[dir1.dir2.etc]
- X#
- X# Once these names have been defined the following commands
- X# can be executed at the command line:
- X#
- X# $ mms install
- X# $ mms test
- X# $ mms clean
- X#
- X# When "mms test" is executed the diff should not show any differences. In fact
- X# the same effect can be achieved by
- X#
- X# $ mms install, test, clean
- X#
- X# The filename of the the mms description file, i.e., this file,
- X# should either be "makefile." or "decrip.mms"
- X#
- X# VMS make file for "flex" tool
- X
- X# Redefine the following for your own environment
- XBIN = tools$$exe
- XLIB = tools$$library
- XMAN = tools$$manual
- XGNULIB = <******directory where you keep alloca.obj and bcopy.obj***>
- X
- XSKELETON_FILE = "DEFAULT_SKELETON_FILE=""$(LIB):FLEX.SKEL"""
- X
- XCCFLAGS = VMS,USG
- XFLEX_FLAGS = -is
- X
- XFLEXOBJS = ccl.obj dfa.obj ecs.obj gen.obj main.obj misc.obj nfa.obj -
- X parse.obj scan.obj sym.obj tblcmp.obj yylex.obj
- X
- XOBJ = ccl.obj,dfa.obj,ecs.obj,gen.obj,main.obj,misc.obj,nfa.obj,parse.obj, -
- X scan.obj,sym.obj,tblcmp.obj,yylex.obj
- X
- Xdefault : flex
- X ! installed FLEX
- X
- Xinstall : lib man bin
- X !Installed FLEX and LIBRARIES
- X
- Xlib : $(LIB):flex.skel
- X ! Installed $(LIB):flex.skel
- X
- Xbin : $(BIN):flex.exe
- X flex :== $ $(BIN):flex.exe
- X
- Xman : $(MAN):flex.doc
- X ! installed $(MAN):flex.doc
- X
- X$(LIB):flex.skel : flex.skel
- X copy flex.skel $(LIB):flex.skel
- X$(BIN):flex.exe : flex.exe
- X copy flex.exe $(BIN):flex.exe
- X$(MAN):flex.doc : flex.1
- X copy flex.1 $(MAN):flex.doc
- X
- Xflex : flex.exe
- X copy flex.exe $(BIN):flex.exe
- X
- Xflex.exe : $(FLEXOBJS)
- X link /exe=flex.exe -
- X $(OBJ), -
- X $(GNULIB)alloca.obj, -
- X $(GNULIB)bcopy.obj
- X
- X
- Xparse.c : parse.y
- X bison/defines/verbose/fixed_outfiles parse.y
- X copy y_tab.c parse.c
- X del/noconfirm y_tab.c;*
- X
- Xparse.h : parse.c
- X copy y_tab.h parse.h
- X del/noconfirm y_tab.h;*
- X
- Xscan.c : initscan.c
- X copy initscan.c scan.c
- X
- Xccl.obj : ccl.c flexdef.h
- X cc /define=($(CCFLAGS)) ccl.c
- Xdfa.obj : dfa.c flexdef.h
- X cc /define=($(CCFLAGS)) dfa.c
- Xecs.obj : ecs.c flexdef.h
- X cc /define=($(CCFLAGS)) ecs.c
- Xgen.obj : gen.c flexdef.h
- X cc /define=($(CCFLAGS)) gen.c
- Xmain.obj : main.c flexdef.h
- X cc /define=($(CCFLAGS),$(SKELETON_FILE)) main.c
- Xmisc.obj : misc.c flexdef.h
- X cc /define=($(CCFLAGS)) misc.c
- Xnfa.obj : nfa.c flexdef.h
- X cc /define=($(CCFLAGS)) nfa.c
- Xparse.obj : parse.c flexdef.h parse.h
- X cc /define=($(CCFLAGS)) parse.c
- Xscan.obj : scan.c parse.h flexdef.h
- X cc /define=($(CCFLAGS)) scan.c
- Xsym.obj : sym.c flexdef.h
- X cc /define=($(CCFLAGS)) sym.c
- Xtblcmp.obj : tblcmp.c flexdef.h
- X cc /define=($(CCFLAGS)) tblcmp.c
- Xyylex.obj : yylex.c parse.h flexdef.h
- X cc /define=($(CCFLAGS)) yylex.c
- X
- Xclean :
- X ! Cleaning up by deleting unnecessary object files etc.
- X - delete/noconfirm scan.c;*
- X - delete/noconfirm parse.c;*
- X - delete/noconfirm parse.h;*
- X - delete/noconfirm lexyy.c;*
- X - delete/noconfirm *.obj;*
- X - delete/noconfirm flex*.tmp;*
- X - delete/noconfirm y.output;*
- X - delete/noconfirm *.diff;*
- X - delete/noconfirm y_tab.*;*
- X - purge/log
- X
- Xtest : $(BIN):flex.exe
- X flex :== $ $(BIN):flex.exe
- X define tools$$library 'f$environment("default")'
- X sho log tool$$library
- X flex $(FLEX_FLAGS) scan.l
- X diff/out=flex.diff initscan.c lexyy.c
- X type/page flex.diff
- END_OF_FILE
- if test 3537 -ne `wc -c <'MISC/Makefile.VMS'`; then
- echo shar: \"'MISC/Makefile.VMS'\" unpacked with wrong size!
- fi
- # end of 'MISC/Makefile.VMS'
- fi
- if test -f 'MISC/README' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'MISC/README'\"
- else
- echo shar: Extracting \"'MISC/README'\" \(520 characters\)
- sed "s/^X//" >'MISC/README' <<'END_OF_FILE'
- XMiscellaneous flex stuff. In here you'll find:
- X
- X - a VMS makefile for flex
- X
- X - out-of-date patches for flex on the Atari and for Minix,
- X from Ronald Lamprecht (V61%DHDURZ1.BITNET@CUNYVM.CUNY.EDU,
- X ...!unido!DHDURZ1.bitnet!V61, V61@DHDURZ1 (Bitnet));
- X
- X - somewhat out-of-date notes on porting flex to MS-DOS, from
- X Jeffrey R. Jones (jjones@angate.att.com);
- X
- X - notes on porting flex to Turbo-C, from Frank Whaley (few@quad1.quad.com,
- X uunet!ccicpg!quad1!few).
- X
- XUpdated versions of these will be welcome!
- END_OF_FILE
- if test 520 -ne `wc -c <'MISC/README'`; then
- echo shar: \"'MISC/README'\" unpacked with wrong size!
- fi
- # end of 'MISC/README'
- fi
- if test -f 'MISC/Turbo-C.notes' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'MISC/Turbo-C.notes'\"
- else
- echo shar: Extracting \"'MISC/Turbo-C.notes'\" \(6089 characters\)
- sed "s/^X//" >'MISC/Turbo-C.notes' <<'END_OF_FILE'
- X(Message inbox:25)
- XDate: Tue, 29 Aug 89 18:57:48 pst
- XFrom: few@quad1.quad.com (Frank Whaley)
- XSubject: Re: flex 2.1 for Turbo C
- XTo: vern@cs.cornell.edu
- X
- X> Sorry it's taken me so long to get back to you - I've been out of touch
- X> for about the last month.
- X
- XI didn't expect to hear from you soon -- hope your journey was nice.
- X
- X> I'd like to have your 'adjustments' for Turbo C, so if you still have
- X> them lying conveniently around, please mail them to me. Thanks.
- X
- XAfter a little more fiddling, the changes are relatively small. Probably
- Xthe largest problem is that Turbo C does not yet claim to adhere to the
- Xdraft standard, so even though they support many "modern" constructs, they
- Xstill are not __STDC__. Thus the diffs from flex.skl (note the name):
- X
- X 62c62
- X < #if defined(__STDC__) || defined(__TURBOC__)
- X ---
- X > #ifdef __STDC__
- X 104c104
- X < #if !(defined(__STDC__) || defined(__TURBOC__))
- X ---
- X > #ifndef __STDC__
- X 134c134
- X < #if defined(__STDC__) || defined(__TURBOC__)
- X ---
- X > #ifdef __STDC__
- X 390c390
- X < #if defined(__STDC__) || defined(__TURBOC__)
- X ---
- X > #ifdef __STDC__
- X 482c482
- X < #if defined(__STDC__) || defined(__TURBOC__)
- X ---
- X > #ifdef __STDC__
- X
- Xand initscan.c:
- X
- X 63c63
- X < #if defined(__STDC__) || defined(__TURBOC__)
- X ---
- X > #ifdef __STDC__
- X 105c105
- X < #if !(defined(__STDC__) || defined(__TURBOC__))
- X ---
- X > #ifndef __STDC__
- X 677c677
- X < #if defined(__STDC__) || defined(__TURBOC__)
- X ---
- X > #ifdef __STDC__
- X 1658c1658
- X < #if defined(__STDC__) || defined(__TURBOC__)
- X ---
- X > #ifdef __STDC__
- X 1750c1750
- X < #if defined(__STDC__) || defined(__TURBOC__)
- X ---
- X > #ifdef __STDC__
- X
- Xare pretty simple. BTW, simply adding -D__STDC__=1 to CFLAGS works, but
- X__STDC__ is used in many Turbo C header files, and can confuse things.
- XIt would also mean that all flex-generated code must be compiled with
- Xthat flag.
- X
- Xflexdef.h also had one small problem:
- X
- X 44,46c44
- X < #ifndef MS_DOS
- X < char *memset(); /* should be declared in string.h */
- X < #endif
- X ---
- X > char *memset();
- X
- Xas the Turbo C definiton of memset() is:
- X void *memset(void *s, int c, size_t n);
- X
- XThe 128-byte command line limit of MS-DOS prevents us from using tcc to
- Xlink the objects together, so I provide a tlink script, flex.lnk:
- X-----
- X\turboc\lib\c0l+
- Xccl+
- Xdfa+
- Xecs+
- Xgen+
- Xmain+
- Xmisc+
- Xnfa+
- Xparse+
- Xscan+
- Xsym+
- Xtblcmp+
- Xyylex
- Xflex.exe
- X
- X\turboc\lib\cl
- X-----
- X
- XThe blank line is required.
- X
- XThe makefile needed a lot of hacking, so here it is in its entirety.
- XI don't think it is completely finished, but I'll be happy to work on
- Xit more if you'd like. Some of the changes are specific to my environment
- X(my yacc outputs ytab.c and ytab.h) and most MS-DOS people won't have
- Xcp, mv and rm. Some people like separate makefiles for different
- Xsystems, but we like one makefile with obscene parameterization.
- X
- XI should note that all of my experiments with FLEX_FLAGS=-{c,f,F,e}
- Xhave failed, mostly due to scan.c becoming too large to be a single
- Xmodule. Damn toy operating system.
- X-----
- X# make file for "flex" tool
- X
- X# @(#) $Header: Makefile,v 2.3 89/06/20 17:27:12 vern Exp $ (LBL)
- X
- X# Porting considerations:
- X#
- X# For BSD machines:
- X# CFLAGS =
- X# LDFLAGS = -s
- X# LINK = $(CC) $(CFLAGS) -o flex $(LDFLAGS) $(FLEXOBJS)
- X# SKELETON_DIR = .
- X# SKELETON_FILE = flex.skel
- X# SKELFLAGS = -DDEFAULT_SKELETON_FILE=\"$(SKELETON_DIR)/$(SKELETON_FILE)\"
- X# O = o
- X# YTAB = y.tab
- X# FLEX = ./flex
- X#
- X# For System V Unix or Vax/VMS machines, merely add:
- X# CFLAGS = -DSYS_V
- X#
- X# For MS-DOS, Turbo C:
- XCC = tcc
- XCFLAGS = -DSYS_V -DMS_DOS -O -G -Z -ml -v
- XLINK = tlink @flex.lnk/c/x/v
- XSKELETON_DIR = .
- XSKELETON_FILE = flex.skl
- XSKELFLAGS = -DDEFAULT_SKELETON_FILE="$(SKELETON_DIR)/$(SKELETON_FILE)"
- XO = obj
- XEXE = .exe
- XYTAB = ytab
- XFLEX = flex
- X
- X#
- X# the first time around use "make first_flex"
- X#
- X
- XFLEX_FLAGS =
- X
- XFLEXOBJS = \
- X ccl.$O \
- X dfa.$O \
- X ecs.$O \
- X gen.$O \
- X main.$O \
- X misc.$O \
- X nfa.$O \
- X parse.$O \
- X scan.$O \
- X sym.$O \
- X tblcmp.$O \
- X yylex.$O
- X
- XFLEX_C_SOURCES = \
- X ccl.c \
- X dfa.c \
- X ecs.c \
- X gen.c \
- X main.c \
- X misc.c \
- X nfa.c \
- X parse.c \
- X scan.c \
- X sym.c \
- X tblcmp.c \
- X yylex.c
- X
- Xflex$(EXE): $(FLEXOBJS)
- X $(LINK)
- X
- Xfirst_flex:
- X cp initscan.c scan.c
- X $(MAKE) flex$(EXE)
- X
- Xparse.h parse.c: parse.y
- X $(YACC) -d parse.y
- X @mv $(YTAB).c parse.c
- X @mv $(YTAB).h parse.h
- X
- Xscan.c: scan.l
- X $(FLEX) -ist $(FLEX_FLAGS) scan.l >scan.c
- X
- Xscan.$O: scan.c parse.h
- X
- Xmain.$O: main.c
- X $(CC) $(CFLAGS) -c $(SKELFLAGS) main.c
- X
- Xflex.man: flex.1
- X nroff -man flex.1 >flex.man
- X
- Xlint: $(FLEX_C_SOURCES)
- X lint $(FLEX_C_SOURCES) > flex.lint
- X
- Xdistrib:
- X mv scan.c initscan.c
- X chmod 444 initscan.c
- X $(MAKE) clean
- X
- Xclean:
- X rm -f core errs flex *.$O parse.c *.lint parse.h flex.man tags
- X
- Xtags:
- X ctags $(FLEX_C_SOURCES)
- X
- Xvms: flex.man
- X $(MAKE) distrib
- X
- Xtest:
- X $(FLEX) -ist $(FLEX_FLAGS) scan.l | diff scan.c -
- X-----
- X
- XBTW, thanks for a great tool.
- X
- XFrank Whaley
- XSenior Development Engineer
- XQuadratron Systems Incorporated
- Xfew@quad1.quad.com
- Xuunet!ccicpg!quad1!few
- X(Message inbox:8)
- XDate: Thu, 31 Aug 89 14:57:36 pst
- XFrom: few@quad1.quad.com (Frank Whaley)
- XSubject: Re: flex 2.1 for Turbo C
- XTo: vern@cs.cornell.edu
- X
- X> Thanks for the diffs and Makefile. I'll endeavor to integrate them
- X> into the next release.
- X
- XOne terribly important thing I forgot -- Turbo C (and most MS-DOS C
- Xcompilers) provide only a 4K default stack. Not having thoroughly
- Xtested flex, I can't say that this is enough. The makefile I provided
- Xto you builds a version without stack checking code. I would suggest
- Xadding "-N" to CFLAGS, which will include some simple stack overflow
- Xchecking code. You may wish to include the following lines to main.c:
- X
- X #ifdef __TURBOC__
- X unsigned _stklen = 16384; /* some reasonably large number */
- X #endif
- X
- XIn addition, the flags in the makefile build a version with symbols
- Xfor Turbo Debugger (like -g). You may wan't to leave these flags off
- X(remove "-v" from CFLAGS and "/v" from LINK) or you may wish to provide
- Xan "install" target like so:
- X
- X BINDIR = {/usr/local/bin | c:\bin}
- X STRIP = {strip | tdstrip}
- X
- X install: flex$(EXE)
- X $(CP) flex$(EXE) $(BINDIR)
- X $(STRIP) $(BINDIR)/flex$(EXE)
- X
- XRegards,
- X few
- X
- Xfew@quad1.quad.com
- Xuunet!ccicpg!quad1!few
- X
- END_OF_FILE
- if test 6089 -ne `wc -c <'MISC/Turbo-C.notes'`; then
- echo shar: \"'MISC/Turbo-C.notes'\" unpacked with wrong size!
- fi
- # end of 'MISC/Turbo-C.notes'
- fi
- if test -f 'Makefile' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'Makefile'\"
- else
- echo shar: Extracting \"'Makefile'\" \(4876 characters\)
- sed "s/^X//" >'Makefile' <<'END_OF_FILE'
- X# make file for "flex" tool
- X
- X# @(#) $Header: /usr/fsys/odin/a/vern/flex/RCS/Makefile,v 2.9 90/05/26 17:28:44 vern Exp $ (LBL)
- X
- X# Porting considerations:
- X#
- X# For System V Unix machines, add -DUSG to CFLAGS (if it's not
- X# automatically defined)
- X# For Vax/VMS, add "-DVMS -DUSG" to CFLAGS.
- X# For MS-DOS, add "-DMS_DOS -DUSG" to CFLAGS. Create \tmp if not present.
- X# You will also want to rename flex.skel to something with a three
- X# character extension, change SKELETON_FILE below appropriately,
- X# See MSDOS.notes for more info.
- X# For Amiga, add "-DAMIGA -DUSG" to CFLAGS.
- X# For SCO Unix, add "-DSCO_UNIX" to CFLAGS.
- X#
- X# For C compilers which don't know about "void", add -Dvoid=int to CFLAGS.
- X#
- X# If your C compiler is ANSI standard but does not include the <stdlib.h>
- X# header file (some installations of gcc have this problem), then add
- X# -DDONT_HAVE_STDLIB_H to CFLAGS.
- X#
- X# By default, flex will be configured to generate 8-bit scanners only
- X# if the -8 flag is given. If you want it to always generate 8-bit
- X# scanners, add "-DDEFAULT_CSIZE=256" to CFLAGS. Note that doing
- X# so will double the size of all uncompressed scanners.
- X#
- X# If on your system you have trouble building flex due to 8-bit
- X# character problems, remove the -8 from FLEX_FLAGS and the
- X# "#define FLEX_8_BIT_CHARS" from the beginning of flexdef.h.
- X
- X
- X# the first time around use "make first_flex"
- X
- X
- X# Installation targeting. Files will be installed under the tree rooted
- X# at DESTDIR. User commands will be installed in BINDIR, library files
- X# in LIBDIR (which will be created if necessary), auxiliary files in
- X# AUXDIR, manual pages will be installed in MANDIR with extension MANEXT.
- X# Raw, unformatted troff source will be installed if INSTALLMAN=man, nroff
- X# preformatted versions will be installed if INSTALLMAN=cat.
- XDESTDIR =
- XBINDIR = /usr/local
- XLIBDIR = /usr/local/lib
- XAUXDIR = /usr/local/lib
- XMANDIR = /usr/man/manl
- XMANEXT = l
- XINSTALLMAN = man
- X
- X# MAKE = make
- X
- X
- XSKELETON_FILE = $(DESTDIR)$(AUXDIR)/flex.skel
- XSKELFLAGS = -DDEFAULT_SKELETON_FILE=\"$(SKELETON_FILE)\"
- XCFLAGS = -O
- XLDFLAGS = -s
- X
- XCOMPRESSION =
- XFLEX_FLAGS = -ist8 -Sflex.skel
- X# which "flex" to use to generate scan.c from scan.l
- XFLEX = ./flex
- X# CC = cc
- X
- XAR = ar
- XRANLIB = ranlib
- X
- XFLEXOBJS = \
- X ccl.o \
- X dfa.o \
- X ecs.o \
- X gen.o \
- X main.o \
- X misc.o \
- X nfa.o \
- X parse.o \
- X scan.o \
- X sym.o \
- X tblcmp.o \
- X yylex.o
- X
- XFLEX_C_SOURCES = \
- X ccl.c \
- X dfa.c \
- X ecs.c \
- X gen.c \
- X main.c \
- X misc.c \
- X nfa.c \
- X parse.c \
- X scan.c \
- X sym.c \
- X tblcmp.c \
- X yylex.c
- X
- XFLEX_LIB_OBJS = \
- X libmain.o
- X
- XFLEXLIB = flexlib.a
- X
- X
- Xall : flex $(FLEXLIB)
- X
- Xflex : $(FLEXOBJS)
- X $(CC) $(CFLAGS) -o flex $(LDFLAGS) $(FLEXOBJS)
- X
- Xfirst_flex:
- X cp initscan.c scan.c
- X $(MAKE) $(MFLAGS) flex
- X
- Xparse.h parse.c : parse.y
- X $(YACC) -d parse.y
- X @mv y.tab.c parse.c
- X @mv y.tab.h parse.h
- X
- Xscan.c : scan.l
- X $(FLEX) $(FLEX_FLAGS) $(COMPRESSION) scan.l >scan.c
- X
- Xscan.o : scan.c parse.h flexdef.h
- X
- Xmain.o : main.c flexdef.h
- X $(CC) $(CFLAGS) -c $(SKELFLAGS) main.c
- X
- Xccl.o : ccl.c flexdef.h
- Xdfa.o : dfa.c flexdef.h
- Xecs.o : ecs.c flexdef.h
- Xgen.o : gen.c flexdef.h
- Xmisc.o : misc.c flexdef.h
- Xnfa.o : nfa.c flexdef.h
- Xparse.o : parse.c flexdef.h
- Xsym.o : sym.c flexdef.h
- Xtblcmp.o : tblcmp.c flexdef.h
- Xyylex.o : yylex.c flexdef.h
- X
- Xflex.man : flex.1
- X nroff -man flex.1 >flex.man
- X
- X$(FLEXLIB) : $(FLEX_LIB_OBJS)
- X $(AR) cru $(FLEXLIB) $(FLEX_LIB_OBJS)
- X
- Xlint : $(FLEX_C_SOURCES)
- X lint $(FLEX_C_SOURCES) > flex.lint
- X
- Xdistrib :
- X mv scan.c initscan.c
- X chmod 444 initscan.c
- X $(MAKE) $(MFLAGS) clean
- X
- Xinstall: flex $(DESTDIR)$(LIBDIR) flex.skel install.$(INSTALLMAN) install-lib
- X install -s -m 755 flex $(DESTDIR)$(BINDIR)/flex
- X install -c -m 644 flex.skel $(SKELETON_FILE)
- X
- Xinstall-lib: $(DESTDIR)$(LIBDIR) $(FLEXLIB)
- X install -c -m 644 $(FLEXLIB) $(DESTDIR)$(LIBDIR)/libfl.a
- X $(RANLIB) $(DESTDIR)$(LIBDIR)/libfl.a
- X
- X$(DESTDIR)$(LIBDIR):
- X mkdir $@
- X
- Xinstall.man: flex.1 flexdoc.1
- X install -c -m 644 flex.1 $(DESTDIR)$(MANDIR)/flex.$(MANEXT)
- X install -c -m 644 flexdoc.1 $(DESTDIR)$(MANDIR)/flexdoc.$(MANEXT)
- X
- Xinstall.cat: flex.1 flexdoc.1
- X nroff -h -man flex.1 > $(DESTDIR)$(MANDIR)/flex.$(MANEXT)
- X nroff -h -man flexdoc.1 > $(DESTDIR)$(MANDIR)/flexdoc.$(MANEXT)
- X chmod 644 $(DESTDIR)$(MANDIR)/flex.$(MANEXT)
- X chmod 644 $(DESTDIR)$(MANDIR)/flexdoc.$(MANEXT)
- X
- Xclean :
- X rm -f core errs flex *.o parse.c *.lint parse.h flex.man tags \
- X $(FLEXLIB)
- X
- Xtags :
- X ctags $(FLEX_C_SOURCES)
- X
- Xvms : flex.man
- X $(MAKE) $(MFLAGS) distrib
- X
- Xtest : flex
- X ./flex $(FLEX_FLAGS) $(COMPRESSION) scan.l | diff scan.c -
- X
- Xbigtest :
- X rm -f scan.c ; $(MAKE) COMPRESSION="-C" test
- X rm -f scan.c ; $(MAKE) COMPRESSION="-Ce" test
- X rm -f scan.c ; $(MAKE) COMPRESSION="-Cm" test
- X rm -f scan.c ; $(MAKE) COMPRESSION="-Cfe" test
- X rm -f scan.c ; $(MAKE) COMPRESSION="-CFe" test
- X rm -f scan.c ; $(MAKE) COMPRESSION="-Cf" test
- X rm -f scan.c ; $(MAKE) COMPRESSION="-CF" test
- X rm -f scan.c ; $(MAKE)
- END_OF_FILE
- if test 4876 -ne `wc -c <'Makefile'`; then
- echo shar: \"'Makefile'\" unpacked with wrong size!
- fi
- # end of 'Makefile'
- fi
- if test -f 'Makefile.amiga' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'Makefile.amiga'\"
- else
- echo shar: Extracting \"'Makefile.amiga'\" \(4524 characters\)
- sed "s/^X//" >'Makefile.amiga' <<'END_OF_FILE'
- X# make file for "flex" tool (modified to work with Lattice 5.05)
- X
- X# @(#) $Header: /usr/fsys/odin/a/vern/flex/RCS/Makefile,v 2.9 90/05/26 17:28:44 vern Exp $ (LBL)
- X
- X# Porting considerations:
- X#
- X# For System V Unix machines, add -DUSG to CFLAGS (if it's not
- X# automatically defined)
- X# For Vax/VMS, add "-DVMS -DUSG" to CFLAGS.
- X# For MS-DOS, add "-DMS_DOS -DUSG" to CFLAGS. Create \tmp if not present.
- X# You will also want to rename flex.skel to something with a three
- X# character extension, change SKELETON_FILE below appropriately,
- X# See MSDOS.notes for more info.
- X# For Amiga, add "-DAMIGA -DUSG" to CFLAGS.
- X# For SCO Unix, add "-DSCO_UNIX" to CFLAGS.
- X#
- X# For C compilers which don't know about "void", add -Dvoid=int to CFLAGS.
- X#
- X# If your C compiler is ANSI standard but does not include the <stdlib.h>
- X# header file (some installations of gcc have this problem), then add
- X# -DDONT_HAVE_STDLIB_H to CFLAGS.
- X#
- X# By default, flex will be configured to generate 8-bit scanners only
- X# if the -8 flag is given. If you want it to always generate 8-bit
- X# scanners, add "-DDEFAULT_CSIZE=256" to CFLAGS. Note that doing
- X# so will double the size of all uncompressed scanners.
- X#
- X# If on your system you have trouble building flex due to 8-bit
- X# character problems, remove the -8 from FLEX_FLAGS and the
- X# "#define FLEX_8_BIT_CHARS" from the beginning of flexdef.h.
- X
- X
- X# the first time around use "make first_flex"
- X
- X
- X# Installation targeting. Files will be installed under the tree rooted
- X# at DESTDIR. User commands will be installed in BINDIR, library files
- X# in LIBDIR (which will be created if necessary), auxiliary files in
- X# AUXDIR, manual pages will be installed in MANDIR with extension MANEXT.
- X# Raw, unformatted troff source will be installed if INSTALLMAN=man, nroff
- X# preformatted versions will be installed if INSTALLMAN=cat.
- XDESTDIR =
- XBINDIR = c:unix
- XLIBDIR = s:
- XAUXDIR = s:
- XMANDIR = uuman:
- XMANEXT = doc
- XINSTALLMAN = man
- X
- X# MAKE = make
- X
- X
- XSKELETON_FILE = $(DESTDIR)$(AUXDIR)flex.skel
- X# Cannot get quotes to work correctly with AmigaDOS and LMK.
- X# moved this define to flexdef.h (between ifdef AMIGA...endif) wpl 7/14/90
- X#SKELFLAGS = -dDEFAULT_SKELETON_FILE="$(SKELETON_FILE)"
- XSKELFLAGS =
- XCFLAGS = -O -cwus -dAMIGA -dUSG
- XLDFLAGS = -s
- X
- XCOMPRESSION =
- XFLEX_FLAGS = -ist8 -Sflex.skel
- X# which "flex" to use to generate scan.c from scan.l
- XFLEX = flex
- X# CC = cc
- XYACC = bison
- XMAKE = lmk
- XMFLAGS = -f Makefile.amiga
- X
- XFLEXOBJS = \
- X ccl.o \
- X dfa.o \
- X ecs.o \
- X gen.o \
- X main.o \
- X misc.o \
- X nfa.o \
- X parse.o \
- X scan.o \
- X sym.o \
- X tblcmp.o \
- X yylex.o
- X
- XFLEX_C_SOURCES = \
- X ccl.c \
- X dfa.c \
- X ecs.c \
- X gen.c \
- X main.c \
- X misc.c \
- X nfa.c \
- X parse.c \
- X scan.c \
- X sym.c \
- X tblcmp.c \
- X yylex.c
- X
- Xall : flex
- X
- Xflex : $(FLEXOBJS)
- X blink from lib:c.o $(FLEXOBJS) to flex lib lib:lc.lib lib:amiga.lib
- X
- Xfirst_flex:
- X copy initscan.c scan.c
- X $(MAKE) $(MFLAGS) flex
- X
- Xparse.h parse.c : parse.y
- X $(YACC) -d parse.y
- X @copy parse.tab.c parse.c
- X @copy parse.tab.h parse.h
- X @delete parse.tab.c
- X @delete parse.tab.h
- X
- Xscan.c : scan.l
- X $(FLEX) >scan.c $(FLEX_FLAGS) $(COMPRESSION) scan.l
- X
- Xscan.o : scan.c parse.h flexdef.h
- X
- Xmain.o : main.c flexdef.h
- X $(CC) $(CFLAGS) $(SKELFLAGS) main.c
- X
- Xccl.o : ccl.c flexdef.h
- Xdfa.o : dfa.c flexdef.h
- Xecs.o : ecs.c flexdef.h
- Xgen.o : gen.c flexdef.h
- Xmisc.o : misc.c flexdef.h
- Xnfa.o : nfa.c flexdef.h
- Xparse.o : parse.c flexdef.h
- Xsym.o : sym.c flexdef.h
- Xtblcmp.o : tblcmp.c flexdef.h
- Xyylex.o : yylex.c flexdef.h
- X
- Xinstall : flex flex.skel
- X copy flex $(DESTDIR)$(BINDIR)/flex
- X copy flex.skel $(SKELETON_FILE)
- X
- X#install.man : flex.1 flexdoc.1
- X# install -c -m 644 flex.1 $(DESTDIR)$(MANDIR)flex.$(MANEXT)
- X# install -c -m 644 flexdoc.1 $(DESTDIR)$(MANDIR)flexdoc.$(MANEXT)
- X
- X#install.cat : flex.1 flexdoc.1
- X# nroff -h -man flex.1 > $(DESTDIR)$(MANDIR)/flex.$(MANEXT)
- X# nroff -h -man flexdoc.1 > $(DESTDIR)$(MANDIR)/flexdoc.$(MANEXT)
- X# chmod 644 $(DESTDIR)$(MANDIR)/flex.$(MANEXT)
- X# chmod 644 $(DESTDIR)$(MANDIR)/flexdoc.$(MANEXT)
- X
- X#clean :
- X# rm -f core errs flex *.o parse.c *.lint parse.h flex.man tags \
- X# $(FLEXLIB)
- X
- X#test : flex
- X# ./flex $(FLEX_FLAGS) $(COMPRESSION) scan.l | diff scan.c -
- X
- X#bigtest :
- X# rm -f scan.c ; $(MAKE) COMPRESSION="-C" test
- X# rm -f scan.c ; $(MAKE) COMPRESSION="-Ce" test
- X# rm -f scan.c ; $(MAKE) COMPRESSION="-Cm" test
- X# rm -f scan.c ; $(MAKE) COMPRESSION="-Cfe" test
- X# rm -f scan.c ; $(MAKE) COMPRESSION="-CFe" test
- X# rm -f scan.c ; $(MAKE) COMPRESSION="-Cf" test
- X# rm -f scan.c ; $(MAKE) COMPRESSION="-CF" test
- X# rm -f scan.c ; $(MAKE)
- END_OF_FILE
- if test 4524 -ne `wc -c <'Makefile.amiga'`; then
- echo shar: \"'Makefile.amiga'\" unpacked with wrong size!
- fi
- # end of 'Makefile.amiga'
- fi
- if test -f 'README' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'README'\"
- else
- echo shar: Extracting \"'README'\" \(1599 characters\)
- sed "s/^X//" >'README' <<'END_OF_FILE'
- X// $Header: /usr/fsys/odin/a/vern/flex/RCS/README,v 2.8 90/05/26 17:31:27 vern Exp $
- X
- XThis is release 2.3 of flex - a full release.
- X
- XThe flex distribution consists of the following files:
- X
- X README This message
- X
- X Makefile
- X flexdef.h
- X parse.y
- X scan.l
- X ccl.c
- X dfa.c
- X ecs.c flex sources
- X gen.c
- X main.c
- X misc.c
- X nfa.c
- X sym.c
- X tblcmp.c
- X yylex.c
- X
- X libmain.c flex library (-lfl) source
- X
- X initscan.c pre-flex'd version of scan.l
- X
- X flex.skel skeleton for generated scanners
- X
- X flexdoc.1 full user documentation
- X flex.1 reference documentation
- X
- X Changes Differences between this release and the previous one
- X
- X COPYING flex's copyright
- X
- X MISC/ a directory containing miscellaneous porting-related
- X notes (for Atari, MS-DOS, Turbo-C, and VMS)
- X
- X
- XDecide where you want to keep flex.skel (suggestion: /usr/local/lib),
- Xbut don't move it there yet. Edit "Makefile" and change the definition
- Xof SKELETON_FILE to reflect the full pathname of flex.skel.
- X
- XRead the "Porting considerations" note in the Makefile and make
- Xthe necessary changes.
- X
- XTo make flex for the first time, use:
- X
- X make first_flex
- X
- Xwhich uses the pre-generated copy of the flex scanner (the scanner
- Xitself is written using flex).
- X
- XAssuming it builds successfully, you can test it using
- X
- X make test
- X
- XThe "diff" should not show any differences.
- X
- XIf you're feeling adventurous, issue "make bigtest" and be prepared
- Xto wait a while.
- X
- XInstall flex using:
- X
- X make install
- X
- X
- XPlease send problems and feedback to:
- X
- X vern@cs.cornell.edu
- X decvax!cornell!vern
- X
- X Vern Paxson
- X CS Department
- X 4126 Upson Hall
- X Cornell University
- X Ithaca, NY 14853-7501
- END_OF_FILE
- if test 1599 -ne `wc -c <'README'`; then
- echo shar: \"'README'\" unpacked with wrong size!
- fi
- # end of 'README'
- fi
- if test -f 'ccl.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'ccl.c'\"
- else
- echo shar: Extracting \"'ccl.c'\" \(4115 characters\)
- sed "s/^X//" >'ccl.c' <<'END_OF_FILE'
- X/* ccl - routines for character classes */
- X
- X/*-
- X * Copyright (c) 1990 The Regents of the University of California.
- X * All rights reserved.
- X *
- X * This code is derived from software contributed to Berkeley by
- X * Vern Paxson.
- X *
- X * The United States Government has rights in this work pursuant
- X * to contract no. DE-AC03-76SF00098 between the United States
- X * Department of Energy and the University of California.
- X *
- X * Redistribution and use in source and binary forms are permitted provided
- X * that: (1) source distributions retain this entire copyright notice and
- X * comment, and (2) distributions including binaries display the following
- X * acknowledgement: ``This product includes software developed by the
- X * University of California, Berkeley and its contributors'' in the
- X * documentation or other materials provided with the distribution and in
- X * all advertising materials mentioning features or use of this software.
- X * Neither the name of the University nor the names of its contributors may
- X * be used to endorse or promote products derived from this software without
- X * specific prior written permission.
- X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
- X * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
- X * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- X */
- X
- X#ifndef lint
- Xstatic char rcsid[] =
- X "@(#) $Header: /usr/fsys/odin/a/vern/flex/RCS/ccl.c,v 2.5 90/06/27 23:48:13 vern Exp $ (LBL)";
- X#endif
- X
- X#include "flexdef.h"
- X
- X/* ccladd - add a single character to a ccl
- X *
- X * synopsis
- X * int cclp;
- X * int ch;
- X * ccladd( cclp, ch );
- X */
- X
- Xvoid ccladd( cclp, ch )
- Xint cclp;
- Xint ch;
- X
- X {
- X int ind, len, newpos, i;
- X
- X len = ccllen[cclp];
- X ind = cclmap[cclp];
- X
- X /* check to see if the character is already in the ccl */
- X
- X for ( i = 0; i < len; ++i )
- X if ( ccltbl[ind + i] == ch )
- X return;
- X
- X newpos = ind + len;
- X
- X if ( newpos >= current_max_ccl_tbl_size )
- X {
- X current_max_ccl_tbl_size += MAX_CCL_TBL_SIZE_INCREMENT;
- X
- X ++num_reallocs;
- X
- X ccltbl = reallocate_character_array( ccltbl, current_max_ccl_tbl_size );
- X }
- X
- X ccllen[cclp] = len + 1;
- X ccltbl[newpos] = ch;
- X }
- X
- X
- X/* cclinit - make an empty ccl
- X *
- X * synopsis
- X * int cclinit();
- X * new_ccl = cclinit();
- X */
- X
- Xint cclinit()
- X
- X {
- X if ( ++lastccl >= current_maxccls )
- X {
- X current_maxccls += MAX_CCLS_INCREMENT;
- X
- X ++num_reallocs;
- X
- X cclmap = reallocate_integer_array( cclmap, current_maxccls );
- X ccllen = reallocate_integer_array( ccllen, current_maxccls );
- X cclng = reallocate_integer_array( cclng, current_maxccls );
- X }
- X
- X if ( lastccl == 1 )
- X /* we're making the first ccl */
- X cclmap[lastccl] = 0;
- X
- X else
- X /* the new pointer is just past the end of the last ccl. Since
- X * the cclmap points to the \first/ character of a ccl, adding the
- X * length of the ccl to the cclmap pointer will produce a cursor
- X * to the first free space
- X */
- X cclmap[lastccl] = cclmap[lastccl - 1] + ccllen[lastccl - 1];
- X
- X ccllen[lastccl] = 0;
- X cclng[lastccl] = 0; /* ccl's start out life un-negated */
- X
- X return ( lastccl );
- X }
- X
- X
- X/* cclnegate - negate a ccl
- X *
- X * synopsis
- X * int cclp;
- X * cclnegate( ccl );
- X */
- X
- Xvoid cclnegate( cclp )
- Xint cclp;
- X
- X {
- X cclng[cclp] = 1;
- X }
- X
- X
- X/* list_character_set - list the members of a set of characters in CCL form
- X *
- X * synopsis
- X * int cset[CSIZE];
- X * FILE *file;
- X * list_character_set( cset );
- X *
- X * writes to the given file a character-class representation of those
- X * characters present in the given set. A character is present if it
- X * has a non-zero value in the set array.
- X */
- X
- Xvoid list_character_set( file, cset )
- XFILE *file;
- Xint cset[];
- X
- X {
- X register int i;
- X char *readable_form();
- X
- X putc( '[', file );
- X
- X for ( i = 0; i < csize; ++i )
- X {
- X if ( cset[i] )
- X {
- X register int start_char = i;
- X
- X putc( ' ', file );
- X
- X fputs( readable_form( i ), file );
- X
- X while ( ++i < csize && cset[i] )
- X ;
- X
- X if ( i - 1 > start_char )
- X /* this was a run */
- X fprintf( file, "-%s", readable_form( i - 1 ) );
- X
- X putc( ' ', file );
- X }
- X }
- X
- X putc( ']', file );
- X }
- END_OF_FILE
- if test 4115 -ne `wc -c <'ccl.c'`; then
- echo shar: \"'ccl.c'\" unpacked with wrong size!
- fi
- # end of 'ccl.c'
- fi
- if test -f 'ecs.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'ecs.c'\"
- else
- echo shar: Extracting \"'ecs.c'\" \(8758 characters\)
- sed "s/^X//" >'ecs.c' <<'END_OF_FILE'
- X/* ecs - equivalence class routines */
- X
- X/*-
- X * Copyright (c) 1990 The Regents of the University of California.
- X * All rights reserved.
- X *
- X * This code is derived from software contributed to Berkeley by
- X * Vern Paxson.
- X *
- X * The United States Government has rights in this work pursuant
- X * to contract no. DE-AC03-76SF00098 between the United States
- X * Department of Energy and the University of California.
- X *
- X * Redistribution and use in source and binary forms are permitted provided
- X * that: (1) source distributions retain this entire copyright notice and
- X * comment, and (2) distributions including binaries display the following
- X * acknowledgement: ``This product includes software developed by the
- X * University of California, Berkeley and its contributors'' in the
- X * documentation or other materials provided with the distribution and in
- X * all advertising materials mentioning features or use of this software.
- X * Neither the name of the University nor the names of its contributors may
- X * be used to endorse or promote products derived from this software without
- X * specific prior written permission.
- X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
- X * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
- X * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- X */
- X
- X#ifndef lint
- Xstatic char rcsid[] =
- X "@(#) $Header: /usr/fsys/odin/a/vern/flex/RCS/ecs.c,v 2.5 90/06/27 23:48:17 vern Exp $ (LBL)";
- X#endif
- X
- X#include "flexdef.h"
- X
- X/* ccl2ecl - convert character classes to set of equivalence classes
- X *
- X * synopsis
- X * ccl2ecl();
- X */
- X
- Xvoid ccl2ecl()
- X
- X {
- X int i, ich, newlen, cclp, ccls, cclmec;
- X
- X for ( i = 1; i <= lastccl; ++i )
- X {
- X /* we loop through each character class, and for each character
- X * in the class, add the character's equivalence class to the
- X * new "character" class we are creating. Thus when we are all
- X * done, character classes will really consist of collections
- X * of equivalence classes
- X */
- X
- X newlen = 0;
- X cclp = cclmap[i];
- X
- X for ( ccls = 0; ccls < ccllen[i]; ++ccls )
- X {
- X ich = ccltbl[cclp + ccls];
- X cclmec = ecgroup[ich];
- X
- X if ( xlation && cclmec < 0 )
- X {
- X /* special hack--if we're doing %t tables then it's
- X * possible that no representative of this character's
- X * equivalence class is in the ccl. So waiting till
- X * we see the representative would be disastrous. Instead,
- X * we add this character's equivalence class anyway, if it's
- X * not already present.
- X */
- X int j;
- X
- X /* this loop makes this whole process n^2; but we don't
- X * really care about %t performance anyway
- X */
- X for ( j = 0; j < newlen; ++j )
- X if ( ccltbl[cclp + j] == -cclmec )
- X break;
- X
- X if ( j >= newlen )
- X { /* no representative yet, add this one in */
- X ccltbl[cclp + newlen] = -cclmec;
- X ++newlen;
- X }
- X }
- X
- X else if ( cclmec > 0 )
- X {
- X ccltbl[cclp + newlen] = cclmec;
- X ++newlen;
- X }
- X }
- X
- X ccllen[i] = newlen;
- X }
- X }
- X
- X
- X/* cre8ecs - associate equivalence class numbers with class members
- X *
- X * synopsis
- X * int cre8ecs();
- X * number of classes = cre8ecs( fwd, bck, num );
- X *
- X * fwd is the forward linked-list of equivalence class members. bck
- X * is the backward linked-list, and num is the number of class members.
- X *
- X * Returned is the number of classes.
- X */
- X
- Xint cre8ecs( fwd, bck, num )
- Xint fwd[], bck[], num;
- X
- X {
- X int i, j, numcl;
- X
- X numcl = 0;
- X
- X /* create equivalence class numbers. From now on, abs( bck(x) )
- X * is the equivalence class number for object x. If bck(x)
- X * is positive, then x is the representative of its equivalence
- X * class.
- X */
- X for ( i = 1; i <= num; ++i )
- X if ( bck[i] == NIL )
- X {
- X bck[i] = ++numcl;
- X for ( j = fwd[i]; j != NIL; j = fwd[j] )
- X bck[j] = -numcl;
- X }
- X
- X return ( numcl );
- X }
- X
- X
- X/* ecs_from_xlation - associate equivalence class numbers using %t table
- X *
- X * synopsis
- X * numecs = ecs_from_xlation( ecmap );
- X *
- X * Upon return, ecmap will map each character code to its equivalence
- X * class. The mapping will be positive if the character is the representative
- X * of its class, negative otherwise.
- X *
- X * Returns the number of equivalence classes used.
- X */
- X
- Xint ecs_from_xlation( ecmap )
- Xint ecmap[];
- X
- X {
- X int i;
- X int nul_is_alone = false;
- X int did_default_xlation_class = false;
- X
- X if ( xlation[0] != 0 )
- X {
- X /* if NUL shares its translation with other characters, choose one
- X * of the other characters as the representative for the equivalence
- X * class. This allows a cheap test later to see whether we can
- X * do away with NUL's equivalence class.
- X */
- X for ( i = 1; i < csize; ++i )
- X if ( xlation[i] == -xlation[0] )
- X {
- X xlation[i] = xlation[0];
- X ecmap[0] = -xlation[0];
- X break;
- X }
- X
- X if ( i >= csize )
- X /* didn't find a companion character--remember this fact */
- X nul_is_alone = true;
- X }
- X
- X for ( i = 1; i < csize; ++i )
- X if ( xlation[i] == 0 )
- X {
- X if ( did_default_xlation_class )
- X ecmap[i] = -num_xlations;
- X
- X else
- X {
- X /* make an equivalence class for those characters not
- X * specified in the %t table
- X */
- X ++num_xlations;
- X ecmap[i] = num_xlations;
- X did_default_xlation_class = true;
- X }
- X }
- X
- X else
- X ecmap[i] = xlation[i];
- X
- X if ( nul_is_alone )
- X /* force NUL's equivalence class to be the last one */
- X {
- X ++num_xlations;
- X ecmap[0] = num_xlations;
- X
- X /* there's actually a bug here: if someone is fanatic enough to
- X * put every character in its own translation class, then right
- X * now we just promoted NUL's equivalence class to be csize + 1;
- X * we can handle NUL's class number being == csize (by instead
- X * putting it in its own table), but we can't handle some *other*
- X * character having to be put in its own table, too. So in
- X * this case we bail out.
- X */
- X if ( num_xlations > csize )
- X flexfatal( "too many %t classes!" );
- X }
- X
- X return num_xlations;
- X }
- X
- X
- X/* mkeccl - update equivalence classes based on character class xtions
- X *
- X * synopsis
- X * Char ccls[];
- X * int lenccl, fwd[llsiz], bck[llsiz], llsiz, NUL_mapping;
- X * mkeccl( ccls, lenccl, fwd, bck, llsiz, NUL_mapping );
- X *
- X * where ccls contains the elements of the character class, lenccl is the
- X * number of elements in the ccl, fwd is the forward link-list of equivalent
- X * characters, bck is the backward link-list, and llsiz size of the link-list
- X *
- X * NUL_mapping is the value which NUL (0) should be mapped to.
- X */
- X
- Xvoid mkeccl( ccls, lenccl, fwd, bck, llsiz, NUL_mapping )
- XChar ccls[];
- Xint lenccl, fwd[], bck[], llsiz, NUL_mapping;
- X
- X {
- X int cclp, oldec, newec;
- X int cclm, i, j;
- X static unsigned char cclflags[CSIZE]; /* initialized to all '\0' */
- X
- X /* note that it doesn't matter whether or not the character class is
- X * negated. The same results will be obtained in either case.
- X */
- X
- X cclp = 0;
- X
- X while ( cclp < lenccl )
- X {
- X cclm = ccls[cclp];
- X
- X if ( NUL_mapping && cclm == 0 )
- X cclm = NUL_mapping;
- X
- X oldec = bck[cclm];
- X newec = cclm;
- X
- X j = cclp + 1;
- X
- X for ( i = fwd[cclm]; i != NIL && i <= llsiz; i = fwd[i] )
- X { /* look for the symbol in the character class */
- X for ( ; j < lenccl; ++j )
- X {
- X register int ccl_char;
- X
- X if ( NUL_mapping && ccls[j] == 0 )
- X ccl_char = NUL_mapping;
- X else
- X ccl_char = ccls[j];
- X
- X if ( ccl_char > i )
- X break;
- X
- X if ( ccl_char == i && ! cclflags[j] )
- X {
- X /* we found an old companion of cclm in the ccl.
- X * link it into the new equivalence class and flag it as
- X * having been processed
- X */
- X
- X bck[i] = newec;
- X fwd[newec] = i;
- X newec = i;
- X cclflags[j] = 1; /* set flag so we don't reprocess */
- X
- X /* get next equivalence class member */
- X /* continue 2 */
- X goto next_pt;
- X }
- X }
- X
- X /* symbol isn't in character class. Put it in the old equivalence
- X * class
- X */
- X
- X bck[i] = oldec;
- X
- X if ( oldec != NIL )
- X fwd[oldec] = i;
- X
- X oldec = i;
- Xnext_pt:
- X ;
- X }
- X
- X if ( bck[cclm] != NIL || oldec != bck[cclm] )
- X {
- X bck[cclm] = NIL;
- X fwd[oldec] = NIL;
- X }
- X
- X fwd[newec] = NIL;
- X
- X /* find next ccl member to process */
- X
- X for ( ++cclp; cclflags[cclp] && cclp < lenccl; ++cclp )
- X {
- X /* reset "doesn't need processing" flag */
- X cclflags[cclp] = 0;
- X }
- X }
- X }
- X
- X
- X/* mkechar - create equivalence class for single character
- X *
- X * synopsis
- X * int tch, fwd[], bck[];
- X * mkechar( tch, fwd, bck );
- X */
- X
- Xvoid mkechar( tch, fwd, bck )
- Xint tch, fwd[], bck[];
- X
- X {
- X /* if until now the character has been a proper subset of
- X * an equivalence class, break it away to create a new ec
- X */
- X
- X if ( fwd[tch] != NIL )
- X bck[fwd[tch]] = bck[tch];
- X
- X if ( bck[tch] != NIL )
- X fwd[bck[tch]] = fwd[tch];
- X
- X fwd[tch] = NIL;
- X bck[tch] = NIL;
- X }
- END_OF_FILE
- if test 8758 -ne `wc -c <'ecs.c'`; then
- echo shar: \"'ecs.c'\" unpacked with wrong size!
- fi
- # end of 'ecs.c'
- fi
- if test -f 'flexdoc.uu.ac' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'flexdoc.uu.ac'\"
- else
- echo shar: Extracting \"'flexdoc.uu.ac'\" \(813 characters\)
- sed "s/^X//" >'flexdoc.uu.ac' <<'END_OF_FILE'
- XM($]V92!%=V5R;&ED("AE=V5R;&ED0&UI>F%R+D1O0U,N554N4T4I+@H*("`@M
- XM("!4:&ES('=O<FL@=V%S('!R:6UA<FEL>2!D;VYE('=H96X@22!W87,@(&%T@
- XM("!T:&4@(%)E86P@(%1I;64*("`@("!3>7-T96US("!'<F]U<"!A="!T:&4@Y
- XM3&%W<F5N8V4@0F5R:V5L97D@3&%B;W)A=&]R>2!I;B!"97)K92T*("`@("!L&
- XM97DL($-!+B`@36%N>2`@=&AA;FMS("!T;R`@86QL("!T:&5R92`@9F]R("!TI
- XM:&4@('-U<'!O<G0@($D*("`@("!R96-E:79E9"X*"B`@("`@4V5N9"!C;VUM<
- XM96YT<R!T;SH*"B`@("`@("`@("!697)N(%!A>'-O;@H@("`@("`@("`@0V]MH
- XM<'5T97(@4V-I96YC92!$97!A<G1M96YT"B`@("`@("`@("`T,3(V(%5P<V]N*
- XM($AA;&P*("`@("`@("`@($-O<FYE;&P@56YI=F5R<VET>0H@("`@("`@("`@F
- XM271H86-A+"!.62`Q-#@U,RTW-3`Q"@H@("`@("`@("`@=F5R;D!C<RYC;W)NA
- XM96QL+F5D=0H@("`@("`@("`@9&5C=F%X(6-O<FYE;&PA=F5R;@H*"@H*"@H*J
- XM"@H*5F5R<VEO;B`R+C,@("`@("`@("!,87-T(&-H86YG93H@,C8@36%Y(#$Y$
- X;.3`@("`@("`@("`@("`@("`@("`@,S4*"@H*9
- X``
- Xend
- Xsize 81522
- END_OF_FILE
- if test 813 -ne `wc -c <'flexdoc.uu.ac'`; then
- echo shar: \"'flexdoc.uu.ac'\" unpacked with wrong size!
- fi
- # end of 'flexdoc.uu.ac'
- fi
- if test -f 'libmain.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libmain.c'\"
- else
- echo shar: Extracting \"'libmain.c'\" \(256 characters\)
- sed "s/^X//" >'libmain.c' <<'END_OF_FILE'
- X/* libmain - flex run-time support library "main" function */
- X
- X/* $Header: /usr/fsys/odin/a/vern/flex/RCS/libmain.c,v 1.2 90/05/26 16:50:08 vern Exp $ */
- X
- Xextern int yylex();
- X
- Xint main( argc, argv )
- Xint argc;
- Xchar *argv[];
- X
- X {
- X return yylex();
- X }
- END_OF_FILE
- if test 256 -ne `wc -c <'libmain.c'`; then
- echo shar: \"'libmain.c'\" unpacked with wrong size!
- fi
- # end of 'libmain.c'
- fi
- if test -f 'parse.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'parse.h'\"
- else
- echo shar: Extracting \"'parse.h'\" \(527 characters\)
- sed "s/^X//" >'parse.h' <<'END_OF_FILE'
- X
- X#ifndef YYLTYPE
- Xtypedef
- X struct yyltype
- X {
- X int timestamp;
- X int first_line;
- X int first_column;
- X int last_line;
- X int last_column;
- X char *text;
- X }
- X yyltype;
- X
- X#define YYLTYPE yyltype
- X#endif
- X
- X#define YYACCEPT return(0)
- X#define YYABORT return(1)
- X#define YYERROR goto yyerrlab
- X#ifndef YYSTYPE
- X#define YYSTYPE int
- X#endif
- X#define CHAR 258
- X#define NUMBER 259
- X#define SECTEND 260
- X#define SCDECL 261
- X#define XSCDECL 262
- X#define WHITESPACE 263
- X#define NAME 264
- X#define PREVCCL 265
- X#define EOF_OP 266
- X
- END_OF_FILE
- if test 527 -ne `wc -c <'parse.h'`; then
- echo shar: \"'parse.h'\" unpacked with wrong size!
- fi
- # end of 'parse.h'
- fi
- if test -f 'sym.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'sym.c'\"
- else
- echo shar: Extracting \"'sym.c'\" \(7527 characters\)
- sed "s/^X//" >'sym.c' <<'END_OF_FILE'
- X/* sym - symbol table routines */
- X
- X/*-
- X * Copyright (c) 1990 The Regents of the University of California.
- X * All rights reserved.
- X *
- X * This code is derived from software contributed to Berkeley by
- X * Vern Paxson.
- X *
- X * The United States Government has rights in this work pursuant
- X * to contract no. DE-AC03-76SF00098 between the United States
- X * Department of Energy and the University of California.
- X *
- X * Redistribution and use in source and binary forms are permitted provided
- X * that: (1) source distributions retain this entire copyright notice and
- X * comment, and (2) distributions including binaries display the following
- X * acknowledgement: ``This product includes software developed by the
- X * University of California, Berkeley and its contributors'' in the
- X * documentation or other materials provided with the distribution and in
- X * all advertising materials mentioning features or use of this software.
- X * Neither the name of the University nor the names of its contributors may
- X * be used to endorse or promote products derived from this software without
- X * specific prior written permission.
- X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
- X * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
- X * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- X */
- X
- X#ifndef lint
- Xstatic char rcsid[] =
- X "@(#) $Header: /usr/fsys/odin/a/vern/flex/RCS/sym.c,v 2.4 90/06/27 23:48:36 vern Exp $ (LBL)";
- X#endif
- X
- X#include "flexdef.h"
- X
- X
- X/* declare functions that have forward references */
- X
- Xint hashfunct PROTO((register char[], int));
- X
- X
- Xstruct hash_entry *ndtbl[NAME_TABLE_HASH_SIZE];
- Xstruct hash_entry *sctbl[START_COND_HASH_SIZE];
- Xstruct hash_entry *ccltab[CCL_HASH_SIZE];
- X
- Xstruct hash_entry *findsym();
- X
- X
- X/* addsym - add symbol and definitions to symbol table
- X *
- X * synopsis
- X * char sym[], *str_def;
- X * int int_def;
- X * hash_table table;
- X * int table_size;
- X * 0 / -1 = addsym( sym, def, int_def, table, table_size );
- X *
- X * -1 is returned if the symbol already exists, and the change not made.
- X */
- X
- Xint addsym( sym, str_def, int_def, table, table_size )
- Xregister char sym[];
- Xchar *str_def;
- Xint int_def;
- Xhash_table table;
- Xint table_size;
- X
- X {
- X int hash_val = hashfunct( sym, table_size );
- X register struct hash_entry *sym_entry = table[hash_val];
- X register struct hash_entry *new_entry;
- X register struct hash_entry *successor;
- X
- X while ( sym_entry )
- X {
- X if ( ! strcmp( sym, sym_entry->name ) )
- X { /* entry already exists */
- X return ( -1 );
- X }
- X
- X sym_entry = sym_entry->next;
- X }
- X
- X /* create new entry */
- X new_entry = (struct hash_entry *) malloc( sizeof( struct hash_entry ) );
- X
- X if ( new_entry == NULL )
- X flexfatal( "symbol table memory allocation failed" );
- X
- X if ( (successor = table[hash_val]) )
- X {
- X new_entry->next = successor;
- X successor->prev = new_entry;
- X }
- X else
- X new_entry->next = NULL;
- X
- X new_entry->prev = NULL;
- X new_entry->name = sym;
- X new_entry->str_val = str_def;
- X new_entry->int_val = int_def;
- X
- X table[hash_val] = new_entry;
- X
- X return ( 0 );
- X }
- X
- X
- X/* cclinstal - save the text of a character class
- X *
- X * synopsis
- X * Char ccltxt[];
- X * int cclnum;
- X * cclinstal( ccltxt, cclnum );
- X */
- X
- Xvoid cclinstal( ccltxt, cclnum )
- XChar ccltxt[];
- Xint cclnum;
- X
- X {
- X /* we don't bother checking the return status because we are not called
- X * unless the symbol is new
- X */
- X Char *copy_unsigned_string();
- X
- X (void) addsym( (char *) copy_unsigned_string( ccltxt ), (char *) 0, cclnum,
- X ccltab, CCL_HASH_SIZE );
- X }
- X
- X
- X/* ccllookup - lookup the number associated with character class text
- X *
- X * synopsis
- X * Char ccltxt[];
- X * int ccllookup, cclval;
- X * cclval/0 = ccllookup( ccltxt );
- X */
- X
- Xint ccllookup( ccltxt )
- XChar ccltxt[];
- X
- X {
- X return ( findsym( (char *) ccltxt, ccltab, CCL_HASH_SIZE )->int_val );
- X }
- X
- X
- X/* findsym - find symbol in symbol table
- X *
- X * synopsis
- X * char sym[];
- X * hash_table table;
- X * int table_size;
- X * struct hash_entry *sym_entry, *findsym();
- X * sym_entry = findsym( sym, table, table_size );
- X */
- X
- Xstruct hash_entry *findsym( sym, table, table_size )
- Xregister char sym[];
- Xhash_table table;
- Xint table_size;
- X
- X {
- X register struct hash_entry *sym_entry = table[hashfunct( sym, table_size )];
- X static struct hash_entry empty_entry =
- X {
- X (struct hash_entry *) 0, (struct hash_entry *) 0, NULL, NULL, 0,
- X } ;
- X
- X while ( sym_entry )
- X {
- X if ( ! strcmp( sym, sym_entry->name ) )
- X return ( sym_entry );
- X sym_entry = sym_entry->next;
- X }
- X
- X return ( &empty_entry );
- X }
- X
- X
- X/* hashfunct - compute the hash value for "str" and hash size "hash_size"
- X *
- X * synopsis
- X * char str[];
- X * int hash_size, hash_val;
- X * hash_val = hashfunct( str, hash_size );
- X */
- X
- Xint hashfunct( str, hash_size )
- Xregister char str[];
- Xint hash_size;
- X
- X {
- X register int hashval;
- X register int locstr;
- X
- X hashval = 0;
- X locstr = 0;
- X
- X while ( str[locstr] )
- X hashval = ((hashval << 1) + str[locstr++]) % hash_size;
- X
- X return ( hashval );
- X }
- X
- X
- X/* ndinstal - install a name definition
- X *
- X * synopsis
- X * char nd[];
- X * Char def[];
- X * ndinstal( nd, def );
- X */
- X
- Xvoid ndinstal( nd, def )
- Xchar nd[];
- XChar def[];
- X
- X {
- X char *copy_string();
- X Char *copy_unsigned_string();
- X
- X if ( addsym( copy_string( nd ), (char *) copy_unsigned_string( def ), 0,
- X ndtbl, NAME_TABLE_HASH_SIZE ) )
- X synerr( "name defined twice" );
- X }
- X
- X
- X/* ndlookup - lookup a name definition
- X *
- X * synopsis
- X * char nd[], *def;
- X * char *ndlookup();
- X * def/NULL = ndlookup( nd );
- X */
- X
- XChar *ndlookup( nd )
- Xchar nd[];
- X
- X {
- X return ( (Char *) findsym( nd, ndtbl, NAME_TABLE_HASH_SIZE )->str_val );
- X }
- X
- X
- X/* scinstal - make a start condition
- X *
- X * synopsis
- X * char str[];
- X * int xcluflg;
- X * scinstal( str, xcluflg );
- X *
- X * NOTE
- X * the start condition is Exclusive if xcluflg is true
- X */
- X
- Xvoid scinstal( str, xcluflg )
- Xchar str[];
- Xint xcluflg;
- X
- X {
- X char *copy_string();
- X
- X /* bit of a hack. We know how the default start-condition is
- X * declared, and don't put out a define for it, because it
- X * would come out as "#define 0 1"
- X */
- X /* actually, this is no longer the case. The default start-condition
- X * is now called "INITIAL". But we keep the following for the sake
- X * of future robustness.
- X */
- X
- X if ( strcmp( str, "0" ) )
- X printf( "#define %s %d\n", str, lastsc );
- X
- X if ( ++lastsc >= current_max_scs )
- X {
- X current_max_scs += MAX_SCS_INCREMENT;
- X
- X ++num_reallocs;
- X
- X scset = reallocate_integer_array( scset, current_max_scs );
- X scbol = reallocate_integer_array( scbol, current_max_scs );
- X scxclu = reallocate_integer_array( scxclu, current_max_scs );
- X sceof = reallocate_integer_array( sceof, current_max_scs );
- X scname = reallocate_char_ptr_array( scname, current_max_scs );
- X actvsc = reallocate_integer_array( actvsc, current_max_scs );
- X }
- X
- X scname[lastsc] = copy_string( str );
- X
- X if ( addsym( scname[lastsc], (char *) 0, lastsc,
- X sctbl, START_COND_HASH_SIZE ) )
- X format_pinpoint_message( "start condition %s declared twice", str );
- X
- X scset[lastsc] = mkstate( SYM_EPSILON );
- X scbol[lastsc] = mkstate( SYM_EPSILON );
- X scxclu[lastsc] = xcluflg;
- X sceof[lastsc] = false;
- X }
- X
- X
- X/* sclookup - lookup the number associated with a start condition
- X *
- X * synopsis
- X * char str[], scnum;
- X * int sclookup;
- X * scnum/0 = sclookup( str );
- X */
- X
- Xint sclookup( str )
- Xchar str[];
- X
- X {
- X return ( findsym( str, sctbl, START_COND_HASH_SIZE )->int_val );
- X }
- END_OF_FILE
- if test 7527 -ne `wc -c <'sym.c'`; then
- echo shar: \"'sym.c'\" unpacked with wrong size!
- fi
- # end of 'sym.c'
- fi
- if test -f 'yylex.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'yylex.c'\"
- else
- echo shar: Extracting \"'yylex.c'\" \(4244 characters\)
- sed "s/^X//" >'yylex.c' <<'END_OF_FILE'
- X/* yylex - scanner front-end for flex */
- X
- X/*-
- X * Copyright (c) 1990 The Regents of the University of California.
- X * All rights reserved.
- X *
- X * This code is derived from software contributed to Berkeley by
- X * Vern Paxson.
- X *
- X * The United States Government has rights in this work pursuant
- X * to contract no. DE-AC03-76SF00098 between the United States
- X * Department of Energy and the University of California.
- X *
- X * Redistribution and use in source and binary forms are permitted provided
- X * that: (1) source distributions retain this entire copyright notice and
- X * comment, and (2) distributions including binaries display the following
- X * acknowledgement: ``This product includes software developed by the
- X * University of California, Berkeley and its contributors'' in the
- X * documentation or other materials provided with the distribution and in
- X * all advertising materials mentioning features or use of this software.
- X * Neither the name of the University nor the names of its contributors may
- X * be used to endorse or promote products derived from this software without
- X * specific prior written permission.
- X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
- X * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
- X * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- X */
- X
- X#ifndef lint
- Xstatic char rcsid[] =
- X "@(#) $Header: /usr/fsys/odin/a/vern/flex/RCS/yylex.c,v 2.5 90/06/27 23:48:40 vern Exp $ (LBL)";
- X#endif
- X
- X#include <ctype.h>
- X#include "flexdef.h"
- X#include "parse.h"
- X
- X
- X/* ANSI C does not guarantee that isascii() is defined */
- X#ifndef isascii
- X#define isascii(c) ((c) <= 0177)
- X#endif
- X
- X
- X/* yylex - scan for a regular expression token
- X *
- X * synopsis
- X *
- X * token = yylex();
- X *
- X * token - return token found
- X */
- X
- Xint yylex()
- X
- X {
- X int toktype;
- X static int beglin = false;
- X
- X if ( eofseen )
- X toktype = EOF;
- X else
- X toktype = flexscan();
- X
- X if ( toktype == EOF || toktype == 0 )
- X {
- X eofseen = 1;
- X
- X if ( sectnum == 1 )
- X {
- X synerr( "premature EOF" );
- X sectnum = 2;
- X toktype = SECTEND;
- X }
- X
- X else if ( sectnum == 2 )
- X {
- X sectnum = 3;
- X toktype = 0;
- X }
- X
- X else
- X toktype = 0;
- X }
- X
- X if ( trace )
- X {
- X if ( beglin )
- X {
- X fprintf( stderr, "%d\t", num_rules + 1 );
- X beglin = 0;
- X }
- X
- X switch ( toktype )
- X {
- X case '<':
- X case '>':
- X case '^':
- X case '$':
- X case '"':
- X case '[':
- X case ']':
- X case '{':
- X case '}':
- X case '|':
- X case '(':
- X case ')':
- X case '-':
- X case '/':
- X case '\\':
- X case '?':
- X case '.':
- X case '*':
- X case '+':
- X case ',':
- X (void) putc( toktype, stderr );
- X break;
- X
- X case '\n':
- X (void) putc( '\n', stderr );
- X
- X if ( sectnum == 2 )
- X beglin = 1;
- X
- X break;
- X
- X case SCDECL:
- X fputs( "%s", stderr );
- X break;
- X
- X case XSCDECL:
- X fputs( "%x", stderr );
- X break;
- X
- X case WHITESPACE:
- X (void) putc( ' ', stderr );
- X break;
- X
- X case SECTEND:
- X fputs( "%%\n", stderr );
- X
- X /* we set beglin to be true so we'll start
- X * writing out numbers as we echo rules. flexscan() has
- X * already assigned sectnum
- X */
- X
- X if ( sectnum == 2 )
- X beglin = 1;
- X
- X break;
- X
- X case NAME:
- X fprintf( stderr, "'%s'", nmstr );
- X break;
- X
- X case CHAR:
- X switch ( yylval )
- X {
- X case '<':
- X case '>':
- X case '^':
- X case '$':
- X case '"':
- X case '[':
- X case ']':
- X case '{':
- X case '}':
- X case '|':
- X case '(':
- X case ')':
- X case '-':
- X case '/':
- X case '\\':
- X case '?':
- X case '.':
- X case '*':
- X case '+':
- X case ',':
- X fprintf( stderr, "\\%c", yylval );
- X break;
- X
- X default:
- X if ( ! isascii( yylval ) || ! isprint( yylval ) )
- X fprintf( stderr, "\\%.3o", yylval );
- X else
- X (void) putc( yylval, stderr );
- X break;
- X }
- X
- X break;
- X
- X case NUMBER:
- X fprintf( stderr, "%d", yylval );
- X break;
- X
- X case PREVCCL:
- X fprintf( stderr, "[%d]", yylval );
- X break;
- X
- X case EOF_OP:
- X fprintf( stderr, "<<EOF>>" );
- X break;
- X
- X case 0:
- X fprintf( stderr, "End Marker" );
- X break;
- X
- X default:
- X fprintf( stderr, "*Something Weird* - tok: %d val: %d\n",
- X toktype, yylval );
- X break;
- X }
- X }
- X
- X return ( toktype );
- X }
- END_OF_FILE
- if test 4244 -ne `wc -c <'yylex.c'`; then
- echo shar: \"'yylex.c'\" unpacked with wrong size!
- fi
- # end of 'yylex.c'
- fi
- echo shar: End of archive 1 \(of 13\).
- cp /dev/null ark1isdone
- MISSING=""
- for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 13 archives.
- rm -f ark[1-9]isdone ark[1-9][0-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
- --
- Mail submissions (sources or binaries) to <amiga@uunet.uu.net>.
- Mail comments to the moderator at <amiga-request@uunet.uu.net>.
- Post requests for sources, and general discussion to comp.sys.amiga.
-